/**
 * CurDisplayData.java
 * 版权所有(C) 2013
 * 创建者:cuiran 2013-11-27 下午7:17:37
 */
package com.ghyf.mplay.net.data;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.Serializable;


/**
 * 获取当前播放画面
 * @author cuiran
 * @version 1.0.0
 */
public class CurDisplayData implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 3956538932839578053L;
	public static final int textContentLength =	1024;
	/**
	 * 停止回传：0；此时IPAddr，
	 * Port字段无效开始回传：1
	 */
	private byte cmdParam;
	private String ipAddr;
	private int port;
	private String reseved;
	
	public boolean getCurDisplay(byte [] buf_recv, int packetHeaderLength, int curDisplayDataLength){
		ByteArrayInputStream baInPacketData = new ByteArrayInputStream(buf_recv, packetHeaderLength, curDisplayDataLength);
		DataInputStream dInData = new DataInputStream(baInPacketData);
		byte[] buf_temp = new byte[textContentLength];
		
		try
		{
			cmdParam=dInData.readByte();
			dInData.read(buf_temp, 0, 15);
			ipAddr=new String(buf_temp,0,15);
			port=dInData.readInt();
			// maybe we should check data validation here!
			
			// ...
			
			return true;
		}
		catch(IOException e)
		{
		
			return false;
		}
	}
	
	
	
	
	
	/**
	 * 停止回传：0；此时IPAddr，Port字段无效<br>
	 * 开始回传：1
	 * @return the cmdParam
	 */
	public byte getCmdParam() {
		return cmdParam;
	}





	/**
	 * @param cmdParam the cmdParam to set
	 */
	public void setCmdParam(byte cmdParam) {
		this.cmdParam = cmdParam;
	}





	/**
	 * @return the ipAddr
	 */
	public String getIpAddr() {
		return ipAddr.trim();
	}





	/**
	 * @param ipAddr the ipAddr to set
	 */
	public void setIpAddr(String ipAddr) {
		this.ipAddr = ipAddr;
	}





	/**
	 * @return the port
	 */
	public int getPort() {
		return port;
	}





	/**
	 * @param port the port to set
	 */
	public void setPort(int port) {
		this.port = port;
	}





	/**
	 * @return the reseved
	 */
	public String getReseved() {
		return reseved;
	}





	/**
	 * @param reseved the reseved to set
	 */
	public void setReseved(String reseved) {
		this.reseved = reseved;
	}





	public String toString(){
		
		return new String("cmdParam="+cmdParam+" ipAddr="+ipAddr+" port="+port+" reseved="+reseved);
	}
	
	
}
